<?php

/**
* Department module configure
* 
* @author trungdt
* @since Sep 1, 2011
* Change logs
* 
*    
*/

class depmodule_config {
	function form($object) {
		if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();

		$form = new form();
		if (!isset($object->id)) {
			$object->chain_src='';
			$object->source_main='';
			$object->dep_name='';
			$object->list_sub=0;
			// Sep 16, 2011 - trungdt - Add dep_to_section and section_seo_name
			$object->dep_to_section=0;
			$object->section_seo_name='';
			$object->module_name='';
			
		} else {
			$form->meta('id',$object->id);
		}
		
		$form->register("dep_name","Department Name",new textcontrol($object->dep_name,50,false,250,"",true));
		$form->register("chain_src","Source Module to CHAIN",new textcontrol($object->chain_src,50,false,250,"",false));
		$form->register("source_main","Content when Visitor First click on Department",new htmleditorcontrol($object->source_main));
		$form->register("list_sub","List all sub items of nodes",new checkboxcontrol($object->list_sub,true));
		
		$form->register(null,"",new htmlcontrol("If you checked <b>List all sub</b>, System will automatic show all sub items of each selected dep. If not checked, you will see <b>Content when Visitor First click on Department</b>"));
		$module_type=depmodule::__Module_Includeable();
		$form->register("module_name", "Type of Module will be included on bottom", new dropdowncontrol($object->module_name, $module_type));
		// Sep 16. 2011 - trungdt - dep to section
		$form->register("dep_to_section","Generate Dep into Section",new checkboxcontrol($object->dep_to_section,true));
		$form->register("section_seo_name","Host section Seo Name to generate Dep",new textcontrol($object->section_seo_name,50,false,250,"",false));
		//
		$form->register('submit','',new buttongroupcontrol('Save','','Cancel'));
		return $form;
	}

	function update($values,$object) {
		$object->chain_src=$values['chain_src'];
		$object->source_main=$values['source_main'];
		$object->dep_name=$values['dep_name'];
		if (isset($values['list_sub']))
		{
			$object->list_sub=1;
		}
		else
		{
			$object->list_sub=0;
		}
		//
		$object->dep_to_section = empty($values['dep_to_section']) ? 0 : 1;
		$object->section_seo_name=$values['section_seo_name'];
		$object->module_name = $values['module_name'];
		//
		return $object;
	}
}

?>